<?php
/**
 * Created by YuanXiShop.
 * User: YuanXi
 * Date: 2021/6/4 0004
 * Time: 17:11
 */

namespace home;


use models\BaseDao;

class Index extends Home
{
    function index()
    {
        $db = new BaseDao();

        //特价商品
        $this->assign('tjs',$db->select('product',['id','name','logo','money','smoney'],['istj'=>1,'ORDER'=>['id'=>'ASC'],'LIMIT'=>3]));

        //系统公告
        $this->assign('notices',$db->select('article',['id','name'],['cid'=>1,'ORDER'=>['id'=>'ASC'],'LIMIT'=>8]));

        //新品推荐
        $this->assign('tuijian',$db->select('product',['id','name','logo','money','smoney'],['istuijian'=>1,'ORDER'=>['id'=>'ASC'],'LIMIT'=>5]));

        //分类和部分数据
        $cats = $db->select('category',['id','catname'],['pid'=>0,'ORDER'=>['ord'=>'ASC','id'=>'DESC']]);

        $allcats = [];

        foreach ($cats as $v){
            $v['newlists'] = $db->select('product',['id','name','logo','money','smoney'],['cid'=>$v['id'],'state'=>1,'ORDER'=>['id'=>'ASC'],'LIMIT'=>8]);

            $v['selllists'] = $db->select('product',['id','name','logo','money','smoney'],['cid'=>$v['id'],'state'=>1,'ORDER'=>['sellnum'=>'DESC'],'LIMIT'=>5]);

            array_push($allcats, $v);
        }

        $this->assign('allcats', $allcats);
        //首页底部广告

       $this->assign('title','YuanXiShop首页');

       $this->display('index/index');
    }
}